﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Rhino.Mocks;

namespace TDD_UnoGame.Tests
{
    [TestFixture]
    public class UnoGame
    {
        [Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Card_SetNumberOutOfUpperBounds_Throws()
        {
            var testCard = new Card(UnoGameColors.Blue, 10);
        }

        [Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Card_SetNumberOutOfLowerBounds_Throws()
        {
            var testCard = new Card(UnoGameColors.Blue, -1);
        }

        [Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Card_SetColorOutOfBounds_Throws()
        {
            var testCard = new Card((UnoGameColors)5, 2);
        }

        [Test]
        public void Card_SetColor_ColorSet()
        {
            var testCard = new Card(UnoGameColors.Red, 1);

            Assert.AreEqual(UnoGameColors.Red, testCard.Color);
        }

        [Test]
        public void Card_SetNumber_NumberSet()
        {
            var testCard = new Card(UnoGameColors.Blue, 1);

            Assert.AreEqual(1, testCard.Number);
        }

        [Test]
        public void Player_SetCards_CardsSet()
        {
            var list = new List<ICard>();
            var testPlayer = new Player(list);

            Assert.AreSame(list, testPlayer.Cards);
        }

        [Test]
        public void Player_CompareCardsColor_ReturnsTrue()
        {
            var yellowOne = MockRepository.GenerateMock<ICard>();
            yellowOne.Color = UnoGameColors.Yellow;
            yellowOne.Number = 1;
            var yellowThree = MockRepository.GenerateMock<ICard>();
            yellowOne.Color = UnoGameColors.Yellow;
            yellowOne.Number = 3;

            var list = new List<ICard> {yellowOne};
            var testPlayer = new Player(list);


            Assert.IsTrue(testPlayer.CompareCards(yellowThree));
        }

        [Test]
        public void Player_CompareCardsNumber_ReturnsTrue()
        {
            var yellowOne = MockRepository.GenerateMock<ICard>();
            yellowOne.Stub(x => x.Color).Return(UnoGameColors.Yellow);
            yellowOne.Stub(x => x.Number).Return(1);
            var greenOne = MockRepository.GenerateMock<ICard>();
            greenOne.Stub(x => x.Color).Return(UnoGameColors.Green);
            greenOne.Stub(x => x.Number).Return(1);
         

            var list = new List<ICard> { yellowOne };
            var testPlayer = new Player(list);


            Assert.IsTrue(testPlayer.CompareCards(greenOne));
        }

        [Test]
        public void Player_CompareCards_ReturnsFalse()
        {
            var yellowOne = MockRepository.GenerateMock<ICard>();
            yellowOne.Stub(x => x.Color).Return(UnoGameColors.Yellow);
            yellowOne.Stub(x => x.Number).Return(1);
            var greenThree = MockRepository.GenerateMock<ICard>();
            greenThree.Stub(x => x.Color).Return(UnoGameColors.Green);
            greenThree.Stub(x => x.Number).Return(3);

            var list = new List<ICard> { yellowOne };
            var testPlayer = new Player(list);

            Assert.IsFalse(testPlayer.CompareCards(greenThree));
        }

    }
}
